package com.aaa.market.service.impl;

import com.aaa.market.mapper.QuestionMapper;
import com.aaa.market.pojo.entity.Question;
import com.aaa.market.pojo.vo.QuestionVo;
import com.aaa.market.service.QuestionService;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gsj.common.pojo.R;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @program: clms-eighth
 * @description: 客服问题
 * @author: 刘守霖
 * @create: 2021-07-23 19:56
 **/
@Service
public class QuestionServiceImpl implements QuestionService {
    @Autowired
    private QuestionMapper questionMapper;


    @Override
    public R findQuestionByPage(Integer currentPage, Integer pageSize, QuestionVo questionVo) {
        Page<Question> page = new Page<>(currentPage,pageSize);
        QueryWrapper<Question> wrapper=new QueryWrapper<>();
        if (StringUtils.isNotEmpty(questionVo.getSubmodule())){
            wrapper.like("submodule",questionVo.getSubmodule());
        }
        Page<Question> page1 = questionMapper.selectPage(page, wrapper);
        return R.ok().put("records",page1.getRecords()).put("total",page1.getTotal());
    }

    @Override
    public R insertQuestion(Question question) {
        questionMapper.insertQuestionTable(question);
        return null;
    }

    @Override
    public R delQuestion(Integer id) {
        questionMapper.delQuestion(id);
        return null;
    }

    @Override
    public R changeQuestion(Question question) {
        questionMapper.changeQuestion(question);
        return null;
    }

    @Override
    public R chaXun(Integer id) {
        List<Question> questions = questionMapper.chaXun(id);

        return R.ok().put("questions",questions);
    }

    @Override
    public R customerIssues(QuestionVo questionVo) {
        List<Question> customerIssues = questionMapper.customerIssues(questionVo);
        return R.ok().put("customerIssues",customerIssues);
    }

}
